setwd("/Users/innoshuadmin/Dropbox/1RD/revision/drdfinal/simulations/mktable")
require(Hmisc) 
Sys.setenv( PATH=paste(Sys.getenv("PATH"),"/usr/texbin",sep=":") )

load("simu_model_1.RData")
rej_cct_dgp1=cbind(MRDstat[1:3,1:3],DRDstat2[1:3,1:3])
rej_ik_dgp1=cbind(MRDstat[1:3,4:6],DRDstat2[1:3,4:6])
crsize_cct_dgp1=cbind(size2[1:3,1:3],size1[1:3,1:3])
crsize_ik_dgp1=cbind(size2[1:3,4:6],size1[1:3,4:6])

load("simu_model_2.RData")
rej_cct_dgp2=cbind(MRDstat[1:3,1:3],DRDstat2[1:3,1:3])
rej_ik_dgp2=cbind(MRDstat[1:3,4:6],DRDstat2[1:3,4:6])
crsize_cct_dgp2=cbind(size2[1:3,1:3],size1[1:3,1:3])
crsize_ik_dgp2=cbind(size2[1:3,4:6],size1[1:3,4:6])


load("simu_model_3.RData")
rej_cct_dgp3=cbind(MRDstat[1:3,1:3],DRDstat2[1:3,1:3])
rej_ik_dgp3=cbind(MRDstat[1:3,4:6],DRDstat2[1:3,4:6])
crsize_cct_dgp3=cbind(size2[1:3,1:3],size1[1:3,1:3])
crsize_ik_dgp3=cbind(size2[1:3,4:6],size1[1:3,4:6])
crpower_cct_dgp3=cbind(power2[1:3,1:3],power1[1:3,1:3])
crpower_ik_dgp3=cbind(power2[1:3,4:6],power1[1:3,4:6])


cct=rbind(rej_cct_dgp1,rej_cct_dgp2,rej_cct_dgp3,crsize_cct_dgp1,crsize_cct_dgp2,crsize_cct_dgp3,crpower_cct_dgp3)
cct=format.df(cct,2) ## define number of digits in the table.
colnames(cct) <-  c("(1) c=4","(2) c=4.5","(3) c=5","(1) c=4","(2) c=4.5","(3) c=5")
rownames(cct) <- c("n=500","n=1000","n=2000","n=500","n=1000","n=2000","n=500","n=1000","n=2000","n=500","n=1000","n=2000","n=500","n=1000","n=2000","n=500","n=1000","n=2000","n=500","n=1000","n=2000")
latex(cct,file = "simutable_cct.tex") ## make the table.

ik=rbind(rej_ik_dgp1,rej_ik_dgp2,rej_ik_dgp3,crsize_ik_dgp1,crsize_ik_dgp2,crsize_ik_dgp3,crpower_ik_dgp3)
ik=format.df(ik,2) ## define number of digits in the table.
colnames(ik) <-  c("(1) c=4","(2) c=4.5","(3) c=5","(1) c=4","(2) c=4.5","(3) c=5")
rownames(ik) <- c("n=500","n=1000","n=2000","n=500","n=1000","n=2000","n=500","n=1000","n=2000","n=500","n=1000","n=2000","n=500","n=1000","n=2000","n=500","n=1000","n=2000","n=500","n=1000","n=2000")
latex(ik,file = "simutable_ik.tex") ## make the table.
